package xyz.labmem.base.core.consts

import org.slf4j.Logger
import org.slf4j.LoggerFactory
import kotlin.reflect.KClass

/**
 * @Author lty
 * @Date 2021/12/14 15:15
 */

/**
 * 日期格式化Formatter
 */
const val DATE_FORMAT = "yyyy-MM-dd"

/**
 * 时间日期格式化Formatter
 */
const val DATETIME_FORMAT = "yyyy-MM-dd HH:mm:ss"

/**
 * 时间格式化Formatter
 */
const val TIME_FORMAT = "HH:mm:ss"

/**
 * 未知标识
 */
const val UNKNOWN = "Unknown"

/**
 * redis验证码前缀
 */
const val REDIS_CAPTCHA = "Login_Captcha://"

/**
 * 当前登录的用户
 */
const val USER_SESSION_KEY = "thisUser"


/**
 * UTF-8 字符集
 */
const val UTF8 = "UTF-8"

/**
 * GBK 字符集
 */
const val GBK = "GBK"

/**
 * http请求
 */
const val HTTP = "http://"

/**
 * https请求
 */
const val HTTPS = "https://"

/**
 * 通用成功标识
 */
const val SUCCESS = "0"

/**
 * 通用失败标识
 */
const val FAIL = "1"

/**
 * 登录成功
 */
const val LOGIN_SUCCESS = "Success"

/**
 * 注销
 */
const val LOGOUT = "Logout"

/**
 * 注册
 */
const val REGISTER = "Register"

/**
 * 登录失败
 */
const val LOGIN_FAIL = "Error"

/**
 * 验证码 redis key
 */
const val CAPTCHA_CODE_KEY = "captcha_codes:"


/**
 * 登录用户 redis key
 */
const val userKeyPrefix = "authEntity:"

/**
 * 权限
 */
const val permissionKeyPrefix = "authPermission//:"

const val roleKeyPrefix = "authRole//:"


/**
 * 防重提交 redis key
 */
const val REPEAT_SUBMIT_KEY = "repeat_submit:"

/**
 * 限流 redis key
 */
const val RATE_LIMIT_KEY = "rate_limit:"

/**
 * 验证码有效期（分钟）
 */
const val CAPTCHA_EXPIRATION = 2

/**
 * 令牌
 */
const val TOKEN = "token"

/**
 * 令牌前缀
 */
const val TOKEN_PREFIX = "Bearer "

/**
 * 令牌前缀
 */
const val LOGIN_USER_KEY = "login_user_key"

/**
 * 用户ID
 */
const val JWT_USERID = "userid"


/**
 * 用户头像
 */
const val JWT_AVATAR = "avatar"

/**
 * 创建时间
 */
const val JWT_CREATED = "created"

/**
 * 用户权限
 */
const val JWT_AUTHORITIES = "authorities"

/**
 * 参数管理 cache key
 */
const val SYS_CONFIG_KEY = "sys_config:"

/**
 * 字典管理 cache key
 */
const val SYS_DICT_KEY = "sys_dict:"

/**
 * 资源映射路径 前缀
 */
const val RESOURCE_PREFIX = "/profile"

/**
 * RMI 远程方法调用
 */
const val LOOKUP_RMI = "rmi:"

/**
 * LDAP 远程方法调用
 */
const val LOOKUP_LDAP = "ldap:"

/**
 * LDAPS 远程方法调用
 */
const val LOOKUP_LDAPS = "ldaps:"




/**
 * token时效设置ID
 */
const val TIME_CONFIG_ID = "time:out:id"

/**
 * token时效设置名称
 */
const val TIME_CONFIG_NAME = "token时效设置"



//logback日志打印
fun KClass<out Any>.log(): Logger = LoggerFactory.getLogger(this.java)

fun Any.log(): Logger = this::class.log()
